// strlen模拟实现

#include <iostream>
#include <cstring>
#include <cassert>

struct Model {};
struct NonRecursion : public Model {};
struct Recursion : public Model {};

int strlen_self(const char* str, const NonRecursion& nonRecursion)
{
    std::cout << "strlen_self(const char* str, const NonRecursion& nonRecursion)" << std::endl;
    assert(str);
    const char* first = str;
    const char* last = str;
    while(*last != '\0')
    {
        ++last;
    }
    return last - first;
}

int strlen_self(const char* str, const Recursion& recursion)
{
    if(*str == '\0') 
    {
        std::cout << "strlen_self(const char* str, const Recursion& recursion)" << std::endl;
        return 0;
    }
    return strlen_self(++str, recursion) + 1;
}

int main()
{
    const char* str = "ab\\cedf\t";
    // std::cout << strlen(str) << std::endl;
    std::cout << strlen_self(str, NonRecursion()) << std::endl;

    return 0;
}
